<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>拼图游戏</title>
  <style>
    body {
      font-family: 'Microsoft YaHei', sans-serif;
      background-color: #f5f5f5;
      margin: 0;
      padding: 20px;
    }
    .game-container {
      position: relative;
      margin: 0 auto;
      width: 960px;
      text-align: center;
    }
    .control-panel {
      margin-bottom: 20px;
    }
    #hintButton, .difficulty-btn {
      padding: 10px 20px;
      background-color: #4CAF50;
      color: white;
      border: none;
      border-radius: 4px;
      cursor: pointer;
      font-size: 16px;
      margin: 0 5px 10px;
    }
    #hintButton:hover, .difficulty-btn:hover {
      background-color: #45a049;
    }
    .difficulty-btn.active {
      background-color: #2E7D32;
      font-weight: bold;
    }
    canvas {
      display: block;
      margin: 0 auto;
      border: 1px solid #ddd;
      background-color: #fff;
    }
    .game-description {
      margin-top: 20px;
      font-size: 14px;
      color: #666;
      text-align: left;
    }
    .game-areas {
      display: flex;
      justify-content: space-between;
      position: relative;
    }
    .area-label {
      position: absolute;
      top: 10px;
      left: 10px;
      font-size: 14px;
      color: #666;
      background: rgba(255,255,255,0.7);
      padding: 2px 8px;
      border-radius: 4px;
    }
  </style>
</head>
<body>
  <div class="game-container">
    <div class="control-panel">
      <button class="difficulty-btn" data-level="easy">初级 (3×3)</button>
      <button class="difficulty-btn" data-level="medium">中级 (4×4)</button>
      <button class="difficulty-btn" data-level="hard">高级 (5×5)</button>
      <button id="hintButton">提示</button>
    </div>
    <canvas id="puzzleCanvas" width="960" height="600"></canvas>
    <div class="game-description">
      <p>游戏说明：根据难度选择，拼图会被分为9片、16片或25片，或选择不规则形状模式。拖动碎片到正确位置，碎片会自动吸附固定。放在错误位置时，碎片会自动返回操作区。点击"提示"按钮可以获取帮助。</p>
    </div>
  </div>
  <script src="https://cdn.jsdelivr.net/npm/d3-delaunay@6"></script>
  <script src="puzzle.js"></script>
</body>
</html>